
package server;




import configs.CubeConfig;
import constants.JobConstants;
import kotlin.Metadata;
import kotlin.TypeCastException;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import provider.MapleData;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
import kotlin.Triple;

import java.io.File;
import java.util.HashMap;
import java.util.Map;







 public class MapleUnionFactory {
    private static final HashMap<Integer, BoardInfoEntry> boardInfos = new HashMap<Integer, BoardInfoEntry>();
    /*  12 */   private static final HashMap<Integer, HashMap<Object, Object>> characterSizes = new HashMap<Integer, HashMap<Object, Object>>();
    /*  13 */   private static final HashMap<Integer, Integer> boardInfoSkillIDs = new HashMap<Integer, Integer>();
    /*  14 */   private static final HashMap<Integer, Integer> cardSkillIDs = new HashMap<Integer, Integer>();
    /*  15 */   private static final HashMap<Integer, HashMap<Object, Object>> unionRanks = new HashMap<Integer, HashMap<Object, Object>>();
    public static  MapleUnionFactory INSTANCE ;
    static {
        MapleUnionFactory var0 = new MapleUnionFactory();
        INSTANCE = var0;
        /*  11 */
    }




    
     public final Map<Integer, HashMap<Object, Object>> getUnionRank() {
        /*  18 */
        return unionRanks;

    }


    
     public final Object getCharacterSizeData(int n2, int n3) {
        /*  22 */
        if (characterSizes.containsKey(Integer.valueOf(n2))) {
            if (characterSizes.get(Integer.valueOf(n2)) == null) {
                throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.Map<K, *>");
            }
            HashMap<Object, Object> hashMap = characterSizes.get(Integer.valueOf(n3));
            Integer integer = Integer.valueOf(n3);
            if (hashMap == null) {
                throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.Map<K, *>");
            }
            if (hashMap.containsKey(integer)) {
                /*  23 */
                if (characterSizes.get(Integer.valueOf(n2)) == null) {
                }
                Intrinsics.throwNpe();
                return characterSizes.get(Integer.valueOf(n2)).get(Integer.valueOf(n3));

            }
        }
        /*  25 */
        return null;

    }


    
     public final Map<Integer, BoardInfoEntry> getBoardInfos() {
        /*  29 */
        return boardInfos;

    }


    
     public final HashMap<Integer, Integer> getCardSkillIDs() {
        /*  33 */
        return cardSkillIDs;

    }


    
     public final Triple<Integer, Integer, Integer> getCardSkillIDs(int job, int level) {
        /*  37 */
        if (cardSkillIDs.get(Integer.valueOf(job / 10)) == null) {
            throw new TypeCastException("null cannot be cast to non-null type kotlin.Int");
        }
        int skillid = cardSkillIDs.get(Integer.valueOf(job / 10)).intValue();
        /*  38 */
        if (skillid <= 0) {
            /*  39 */
            return null;

        }
        /*  41 */
        return new Triple(Integer.valueOf(skillid - 71000000), Integer.valueOf(skillid), Integer.valueOf(getGrade(job, level)));

    }



    public final int getGrade(int job, int level) {
        /*  45 */
        if (JobConstants.is神之子(job)) {
            /*  46 */
            int i = level;
            if (130 > i) {
                return 159;
            } else if (159 >= i)
                /*  47 */ {
                return 1;
            }

            /*  49 */
            i = level;
            if (160 > i) {
                return 179;
            } else if (179 >= i)
                /*  50 */ {
                return 2;
            }

            /*  52 */
            i = level;
            if (180 > i) {
                return 199;
            } else if (199 >= i)
                /*  53 */ {
                return 3;
            }

            /*  55 */
            i = level;
            if (200 > i) {
                return 249;
            } else if (249 >= i)
                /*  56 */ {
                return 4;
            }

            /*  58 */
            if (level >= 250) {
                /*  59 */
                return 5;

            }

        } else {
            /*  62 */
            int i = level;
            if (60 > i) {
                return 99;
            } else if (99 >= i)
                /*  63 */ {
                return 1;
            }

            /*  65 */
            i = level;
            if (100 > i) {
                return 139;
            } else if (139 >= i)
                /*  66 */ {
                return 2;
            }

            /*  68 */
            i = level;
            if (140 > i) {
                return 199;
            } else if (199 >= i)
                /*  69 */ {
                return 3;
            }

            /*  71 */
            i = level;
            if (200 > i) {
                return 249;
            } else if (249 >= i)
                /*  72 */ {
                return 4;
            }

            /*  74 */
            if (level >= 250) {
                /*  75 */
                return 5;

            }

        }
        /*  78 */
        return -1;

    }



    public final void init() {
        /*  82 */
        MapleData mapleUnionData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Etc.wz")).getData("mapleUnion.img");
        /*  83 */
        for (MapleData boardinfo : mapleUnionData.getChildByPath("BoardInfo")) {
            /*  84 */
            boardInfos.put(Integer.valueOf(Integer.parseInt(boardinfo.getName())), new BoardInfoEntry(MapleDataTool.getInt("xPos", boardinfo, 0), MapleDataTool.getInt("yPos", boardinfo, 0), (MapleDataTool.getInt("changeable", boardinfo, 0) > 0), MapleDataTool.getInt("groupIndex", boardinfo, 0), MapleDataTool.getInt("openLevel", boardinfo, 0)));

        }
        /*  86 */
        for (MapleData characterSizeData : mapleUnionData.getChildByPath("CharacterSize")) {
            /*  87 */
            int id = Integer.parseInt(characterSizeData.getName());
            /*  88 */
            HashMap<Object, Object> characterSize = (HashMap) characterSizes.get(Integer.valueOf(id));
            /*  89 */
            if (characterSize == null) {
                /*  90 */
                characterSize = new HashMap<Object, Object>();
                /*  91 */
                characterSizes.put(Integer.valueOf(id), characterSize);

            }
            /*  93 */
            for (MapleData subData : characterSizeData) {
                /*  94 */
                int int2 = Integer.parseInt(subData.getName());
                /*  95 */
                HashMap<Object, Object> points = (HashMap) characterSize.get(Integer.valueOf(int2));
                /*  96 */
                if (points == null) {
                    /*  97 */
                    points = new HashMap<Object, Object>();
                    /*  98 */
                    characterSize.put(Integer.valueOf(int2), points);

                }
                /* 100 */
                for (MapleData subData_ : subData) {
                    /* 101 */
                    Intrinsics.checkExpressionValueIsNotNull(MapleDataTool.getPoint(subData_), "MapleDataTool.getPoint(subData_)");
                    points.put(Integer.valueOf(Integer.parseInt(subData_.getName())), MapleDataTool.getPoint(subData_));

                }

            }

        }
        /* 105 */
        for (MapleData b5 : mapleUnionData.getChildByPath("BoardInfo")) {
            /* 106 */
            boardInfoSkillIDs.put(Integer.valueOf(Integer.parseInt(b5.getName())), Integer.valueOf(MapleDataTool.getInt("skillID", b5, 0)));

        }
        /* 108 */
        for (MapleData b6 : mapleUnionData.getChildByPath("Card")) {
            /* 109 */
            cardSkillIDs.put(Integer.valueOf(Integer.parseInt(b6.getName())), Integer.valueOf(MapleDataTool.getInt("skillID", b6, 0)));

        }
        /* 111 */
        for (MapleData unionRankData : mapleUnionData.getChildByPath("unionRank")) {
            /* 112 */
            String name = MapleDataTool.getString(unionRankData.getChildByPath("info/name"));
            /* 113 */
            HashMap<Object, Object> unionRankEntrys = new HashMap<>();
            /* 114 */
            int rank = Integer.parseInt(unionRankData.getName());
            /* 115 */
            for (MapleData subData : unionRankData) {
                /* 116 */
                if (!subData.getName().equals("info")) {
                    /* 117 */
                    int subRank = Integer.parseInt(subData.getName());
                    /* 118 */
                    Intrinsics.checkExpressionValueIsNotNull(name, "name");
                    unionRankEntrys.put(Integer.valueOf(subRank), new UnionRankEntry(name, rank, subRank, MapleDataTool.getInt("level", subData, 0), MapleDataTool.getInt("attackerCount", subData, 0), MapleDataTool.getInt("coinStackMax", subData, 0)));

                }

            }
            /* 121 */
            unionRanks.put(Integer.valueOf(rank), unionRankEntrys);

        }

    }

}